perm filename TEXPAR.DIF[TEX,DEK] blob sn#540842 filedate 1980-10-13 generic text, type T, neo UTF8
Here are some important changes to the paragraphing routine, noticed while
I was writing a paper about it.
a) There was a bug when someone requested e.g. \loose-1 and there is no way
to set the paragraph one line short TEX forced it to be short by using an
overfull last line (sometimes).
b) There was another bug with looseness, the routine that tried to figure out
which alternative to choose was all screwed up, horribly crazy logic, very
embarrassing, although it worked in all the test cases (just lucky).
c) An important optimization has been made, this makes the routine run
significantly faster and use significantly less memory. (The idea is not to
create a break node for each setting when the total badness for that setting
exceeds the total badness for another setting by more than the adjacent-line-
setting-incompatibility penalty.)

  1) TEXPAR.OLD[TEX,DEK] and 2) TEXPAR.NEW[TEX,DEK]	10-13-80 08:55	pages 1,1

**** File 1) TEXPAR.OLD[TEX,DEK]/1P/135L
1)	integer easyline # smallest line number for which limited break nodes are OK;
1)	integer q,p,prevp,n,t,ll,r,targline,delta;
1)	integer bestbet; real bestscore,correction;
**** File 2) TEXPAR.NEW[TEX,DEK]/1P/135L
2)	real leastbadness # minimum of lowestbadness[0],...,lowestbadness[3];
2)	integer easyline # smallest line number for which limited break nodes are OK;
2)	integer q,p,prevp,n,t,ll,r,s;
2)	integer bestbet; real bestscore,correction;
***************


**** File 1) TEXPAR.OLD[TEX,DEK]/1P/168L
1)			for setting←0 thru 3 do if lowestbadness[setting]<infty then
1)				begin integer q; comment we need a new break node;
**** File 2) TEXPAR.NEW[TEX,DEK]/1P/169L
2)			if leastbadness<infty then
2)			  begin for setting←0 thru 3 do if lowestbadness[setting]<infty then
2)			    begin if lowestbadness[setting]≤leastbadness+adjpen/10000 then
2)				begin integer q; comment we need a new break node;
***************


**** File 1) TEXPAR.OLD[TEX,DEK]/1P/200L
1)				lowestbadness[setting]←infty;
1)				mem[q]←r; mem[prevr]←q; prevr←q;
1)				end;
1)			if r=0 then done;
**** File 2) TEXPAR.NEW[TEX,DEK]/1P/203L
2)				mem[q]←r; mem[prevr]←q; prevr←q;
2)				end;
2)			    lowestbadness[setting]←infty;
2)			    end;
2)			  leastbadness←infty;
2)			  end;
2)			if r=0 then done;
***************


**** File 1) TEXPAR.OLD[TEX,DEK]/1P/239L
1)		if badness=infty then
1)			begin comment break node r should become inactive;
1)			mem[prevr]←mem[r]; mem[r]←mem[inactive]; mem[inactive]←r;
1)			if secondpass and (mem[active]=0 or penalt=-infty) then
1)				begin comment On the second pass, we dare not lose all
**** File 2) TEXPAR.NEW[TEX,DEK]/1P/245L
2)		if badness=infty or penalt=-infty then
2)			begin comment break node r should become inactive;
2)			mem[prevr]←mem[r]; mem[r]←mem[inactive]; mem[inactive]←r;
2)			if secondpass and mem[active]=0 and leastbadness=infty then
2)				begin comment On the second pass, we dare not lose all
***************


**** File 1) TEXPAR.OLD[TEX,DEK]/1P/249L
1)			else continue;
1)			end
1)		else	begin prevr←r;
1)			if badness>threshold and penalt>-infty then continue;
1)			end;
**** File 2) TEXPAR.NEW[TEX,DEK]/1P/255L
2)			else if badness=infty then continue;
2)			end
2)		else	begin prevr←r;
2)			if badness>threshold then continue;
2)			end;
***************


**** File 1) TEXPAR.OLD[TEX,DEK]/1P/257L
1)		else badness←(badness+.01)↑2 # see below for the "-infty" (linebreak) case;
1)		if hyph and (lineno(r) land 4) then badness←badness+penpen/10000
**** File 2) TEXPAR.NEW[TEX,DEK]/1P/263L
2)		else badness←(badness+.01)↑2 # -infty denotes a forced line break;
2)		if hyph and (lineno(r) land 4) then badness←badness+penpen/10000
***************


**** File 1) TEXPAR.OLD[TEX,DEK]/1P/267L
1)			end;
1)		end;
1)	if penalt=-infty then
1)		begin comment For line-breaks we purge all nodes from the active list
1)			except those just inserted;
1)		prevr←active;
1)		while r←mem[prevr] do if curbrk(r)=p then prevr←r else
1)			begin mem[prevr]←mem[r]; mem[r]←mem[inactive]; mem[inactive]←r;
1)			end;
**** File 2) TEXPAR.NEW[TEX,DEK]/1P/273L
2)			if badness<leastbadness then leastbadness←badness;
2)			end;
***************


**** File 1) TEXPAR.OLD[TEX,DEK]/1P/283L
1)	lowestbadness[0]←lowestbadness[1]←lowestbadness[2]←lowestbadness[3]←infty;
1)	if parshape then easyline←mem[parshape]
**** File 2) TEXPAR.NEW[TEX,DEK]/1P/282L
2)	lowestbadness[0]←lowestbadness[1]←lowestbadness[2]←lowestbadness[3]←
2)		leastbadness←infty;
2)	if parshape then easyline←mem[parshape]
***************


**** File 1) TEXPAR.OLD[TEX,DEK]/1P/406L
1)				targline←ll+loose; delta←abs(loose);
1)				if loose then
**** File 2) TEXPAR.NEW[TEX,DEK]/1P/406L
2)				s←0;
2)				if loose then
***************


**** File 1) TEXPAR.OLD[TEX,DEK]/1P/412L
1)						d←delta-abs(targline-l);
1)						if d>0 then
1)							begin bestbet←q; ll←l;
1)							delta←abs(targline-ll);
1)							lowbad←totbad(q);
1)							end
1)						else if d=0 and totbad(q)<lowbad then
1)							begin lowbad←totbad(q); bestbet←q;
**** File 2) TEXPAR.NEW[TEX,DEK]/1P/412L
2)						d←l-ll;
2)						if (d<s and loose≤d) or (d>s and loose≥d) then
2)							begin bestbet←q; s←d;
2)							lowbad←totbad(q);
2)							end
2)						else if d=s and totbad(q)<lowbad then
2)							begin lowbad←totbad(q); bestbet←q;
***************


**** File 1) TEXPAR.OLD[TEX,DEK]/1P/423L
1)					end;
1)				if secondpass or delta=0 then done;
1)				end;
**** File 2) TEXPAR.NEW[TEX,DEK]/1P/422L
2)					ll←ll+s;
2)					end;
2)				if secondpass or s=loose then done;
2)				end;
***************